package com.example.xpvideo.Controller;

import com.example.xpvideo.entity.PageResult;
import com.example.xpvideo.entity.ResponseResult;
import com.example.xpvideo.entity.req.*;
import com.example.xpvideo.entity.res.CommodityDetailRes;
import com.example.xpvideo.entity.res.CommodityListRes;
import com.example.xpvideo.entity.res.PHPCommodityDetailRes;
import com.example.xpvideo.entity.res.PHPCommodityRes;
import com.example.xpvideo.service.LsGoodsService;
import com.example.xpvideo.service.PhpGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

import java.util.List;

/**商品管理
 *
 * @author : 洪俊新
 * @date : 2021/8/16 14:39
 * @description:
 */
@RestController
@RequestMapping("/back/phpcommodity")
public class PHPCommodityController {
    @Autowired
    private PhpGoodsService phpGoodsService;

    /**
     * 首页商品列表
     * */
    @GetMapping("/list")
    public ResponseResult<PageResult<List<PHPCommodityRes>>> list(PHPCommodityReq phpCommodityReq)
            throws Exception{
        return phpGoodsService.list(phpCommodityReq);
    }
    /**
     * 首页商品详情
     * */
    @GetMapping("/detail")
    public ResponseResult<PHPCommodityDetailRes> detail(@NotNull Integer goodsId)
            throws Exception{
        return phpGoodsService.detail(goodsId);
    }

    /**
     * 首页商品审核
     * */
    @PostMapping("/audit")
    public ResponseResult<Object> audit(@NotNull @RequestBody
                                        PhpCommodityAuditReq phpCommodityAuditReq) throws Exception{
        return phpGoodsService.Audit(phpCommodityAuditReq);
    }

    /**
     * 首页商品上下架
     * */
    @PostMapping("/offshelf")
    public ResponseResult<Object> offShelf(@NotNull @RequestBody
                                                UpdateReq updateReq) throws Exception{
        return phpGoodsService.OffShelf(updateReq);
    }

    /**
     * 首页商品置顶
     * */
    @PostMapping("/top")
    public ResponseResult<Object> top(@NotNull @RequestBody
                                      PhpTopGoodsReq phpTopGoodsReq) throws Exception{
        return phpGoodsService.top(phpTopGoodsReq);
    }

}
